﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Models;

namespace SQPlugin
{
    /// <summary>
    /// Inteface that all SuperQuery database plug ins need to consume so that SuperQuery can talk to them
    /// </summary>
    public interface ISQPlugin
    {
        /// <summary>
        /// Unique ID that this plug in must have so that SuperQuery can differentiate it from other plug ins
        /// </summary>
        Guid PlugInID
        {
            get;
        }

        /// <summary>
        /// A discriptive name for this plug in
        /// </summary>
        string PluginName
        {
            get;
        }

        /// <summary>
        /// Initialise and return the Edit Database user control for this plug in
        /// </summary>
        /// <returns>A user control that impliments IEditDatabase</returns>
        IEditDatabase GetEditDatabaseUI();

        /// <summary>
        /// Initialise and return the Server Details user control for this plug in
        /// </summary>
        /// <returns></returns>
        IServerDetails GetServerDetailsUI();

        /// <summary>
        /// Get a list of databases on the specified server
        /// </summary>
        /// <param name="server">The server that we want to retrieve databases from </param>
        /// <param name="errorMsg">If an error occured the message will returned here, otherwise blank</param>
        /// <returns>A list of databases loaded from the specified server</returns>
        List<Database> GetDatabases(Server server, out string errorMsg);

        /// <summary>
        /// Get the results of a query based on the supplied database and query
        /// </summary>
        /// <param name="database">The database to query</param>
        /// <param name="query">The query to run</param>
        /// <returns>A query result</returns>
        QueryResult RunQuery(Database database, Query query);

        /// <summary>
        /// Check to see if the supplied database model can actually connect the database it is set up to connect to
        /// </summary>
        /// <param name="database">The database to check</param>
        /// <param name="errorMsg">If an error occured the message will returned here, otherwise blank</param>
        /// <returns>True if the database connects without any errors</returns>
        bool ValidateDatabase(Database database, out string errorMsg);

        /// <summary>
        /// Validate the server object to see if all the correct connection details are provided
        /// </summary>
        /// <param name="server">The server object to validate</param>
        /// <returns>True if the server object contains valid connection details</returns>
        bool ValidateServer(Server server);
    }
}
